<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .app{
            width:94%;
            height:auto;
            overflow:hidden;
            margin:20px auto;
            padding:10px 20px;
            border:#ccc solid 1px;
        }
        .app dl{
            margin:10px 0;
            border:#ccc solid 1px;
            height:auto;
            overflow:hidden;
        }
        .app dl dt{
            display:blick;
            height:36px;
            line-height:36px;
            background:#e6e6e6;
            text-index:10px;
            padding:0 10px;
        }
        .app dl dd{
            float:left;
            margin:0 10px;
            padding:10px 15px;
        }

    </style>
</head>
<body>
<div class="container-fluid" >
    <div class="row">
        <div class="col-sm-9  " style="width: 100%">
            <h3 class="sub-header">节点列表</h3>
            <div class="table-responsive">
                <form action="{:U(GROUP_NAME.'/Rbac/setAccess')}" method="post">
                    <a href="{:U(GROUP_NAME.'/Rbac/role')}" class="btn btn-primary">返回</a>
                    <foreach name="node" item="app">
                        <div class="app">
                            <p>
                                {$app.title} <input type="checkbox" name="access[]" value="{$app.id}_1" level="1" <if condition='$app["access"]'>checked='checked'</if> />
                            </p>
                            <foreach name="app.child" item="action">
                                <dl>
                                    <dt style="color:#f00;">
                                        {$action.title} <input type="checkbox" name="access[]" value="{$action.id}_2" level="2" <if condition='$action["access"]'>checked="checked"</if> />
                                    </dt>
                                    <foreach name="action.child" item="method">
                                        <dd>
                                            <span>{$method.title}</span> <input type="checkbox" name="access[]" value="{$method.id}_3" level="3" <if condition='$method["access"]'>checked="checked"</if> />
                                        </dd>
                                    </foreach>
                                </dl>

                            </foreach>
                        </div>
                    </foreach>
                    <input type="hidden" name="rid" value="{$rid}" />
                    <button class="btn btn-primary">保存</button>
                </form>
            </div>
        </div>
    </div>
</div>
<link href="__PUBLIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="__PUBLIC__/bootstrap/css/button.css" rel="stylesheet">
<script src="__PUBLIC__/bootstrap/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/bootstrap/js/bootstrap.js"></script>

<script type="text/javascript" src="__PUBLIC__/Js/jquery-1.7.2.min.js"></script>
<script>
    $(function(){
        $('input[level=1]').click(function(){
            var inputs = $(this).parents('.app').find('input');
            $(this).attr('checked')?inputs.attr('checked', 'checked'):inputs.removeAttr('checked');
        });
        $('input[level=2]').click(function(){
            var inputs = $(this).parents('dl').find('input');
            $(this).attr('checked')?inputs.attr('checked', 'checked'):inputs.removeAttr('checked');
        });
    });
</script>
</body>
</html>